package top.kaoshanji.ch03;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Scanner;

/**
 * 代码清单 ch03-02：从控制台读取输入
 * author kaoshanji
 * ^_^
 * create time 2024/11/23 11:26
 */
public class InputTest {

    private static final Logger logger = LogManager.getLogger(InputTest.class);

    public static void main(String[] args) {
        logger.info("...代码清单 ch03-02：从控制台读取输入...");

        // 首先，需要构造一个与"标准输入流"System.in关联的Scanner对象
        Scanner in = new Scanner(System.in);

        // 获得第一个输入
        System.out.println("What is your name? ");
        String name = in.nextLine();

        // 获取第二个输入
        System.out.println("How old are you? ");
        int age = in.nextInt();

        // 控制台输出
        System.out.println("Hello, " + name + ". Next year, you'll be " + (age + 1));

    }

}
